package com.itheima.demo01.Exception;

import java.io.FileNotFoundException;
import java.io.IOException;

public class Demo05Throws {
    public static void main(String[] args) throws IOException {
        readFile("c:\\a.txt");
    }

    public static void readFile(String fileName) throws IOException {
        if (!fileName.equals("c:\\a.txt")) {
            throw new FileNotFoundException("传递的文件路径不是c:\\a.txt");
        }
        if (!fileName.endsWith(".txt")) {
            throw new IOException("文件后缀名不对!");
        }
        System.out.println("路径没有问题,读取文件");
    }
}
